<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace='Rolers' xmlns='http://ibatis.apache.org/mapping' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
  <alias>
    <typeAlias alias='Rolers' assembly='Janus.Mes.POCO.dll' type='Janus.Mes.POCO.Rolers' />
  </alias>
  <resultMaps>
    <resultMap id='RolersResult' class='Rolers'>
	<result property='Code' column='Code ' /> 
	<result property='Level' column='Level ' /> 
	<result property='ParentID' column='ParentID ' /> 
	<result property='Name' column='Name ' /> 
	<result property='Remark' column='Remark ' /> 
		</resultMap>
  </resultMaps>  
  <statements>
  <sql id="UpdaterConditions">  
  <dynamic prepend="SET">
    	<isPropertyAvailable prepend="" property="Code">
        <isNotEmpty prepend="," property="Code">
		          [Code]=#Code#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="Level">
        <isNotEmpty prepend="," property="Level">
		          [Level]=#Level#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="ParentID">
        <isNotEmpty prepend="," property="ParentID">
		          [ParentID]=#ParentID#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="Name">
        <isNotEmpty prepend="," property="Name">
		          [Name]=#Name#
		          </isNotEmpty>
      </isPropertyAvailable>	
	    	<isPropertyAvailable prepend="" property="Remark">
        <isNotEmpty prepend="," property="Remark">
		          [Remark]=#Remark#
		          </isNotEmpty>
      </isPropertyAvailable>	
	  	 </dynamic>
    </sql>
	<sql id="WhereConditions">
	 <dynamic prepend="WHERE">
	 	 <isPropertyAvailable prepend="" property="Code">
        <isNotEmpty prepend="AND" property="Code">
		          [Code]=#Code#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="Level">
        <isNotEmpty prepend="AND" property="Level">
		          [Level]=#Level#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="ParentID">
        <isNotEmpty prepend="AND" property="ParentID">
		          [ParentID]=#ParentID#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="Name">
        <isNotEmpty prepend="AND" property="Name">
		          [Name]=#Name#
		          </isNotEmpty>
      </isPropertyAvailable>
	  	 <isPropertyAvailable prepend="" property="Remark">
        <isNotEmpty prepend="AND" property="Remark">
		          [Remark]=#Remark#
		          </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic> 
    </sql>
	<sql id="InsertPublic">
      INSERT INTO Rolers(
	     <dynamic prepend=" ">
       	   <isPropertyAvailable prepend="" property="Code">
        <isNotEmpty prepend="," property="Code">
          [Code]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="Level">
        <isNotEmpty prepend="," property="Level">
          [Level]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="ParentID">
        <isNotEmpty prepend="," property="ParentID">
          [ParentID]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="Name">
        <isNotEmpty prepend="," property="Name">
          [Name]
        </isNotEmpty>
      </isPropertyAvailable>
	  	   <isPropertyAvailable prepend="" property="Remark">
        <isNotEmpty prepend="," property="Remark">
          [Remark]
        </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic>
      )
      VALUES
      (
	   <dynamic prepend=" ">
      	<isPropertyAvailable prepend="" property="Code">
        <isNotEmpty prepend="," property="Code">		
         #Code#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="Level">
        <isNotEmpty prepend="," property="Level">		
         #Level#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="ParentID">
        <isNotEmpty prepend="," property="ParentID">		
         #ParentID#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="Name">
        <isNotEmpty prepend="," property="Name">		
         #Name#		
        </isNotEmpty>
      </isPropertyAvailable>
	  	<isPropertyAvailable prepend="" property="Remark">
        <isNotEmpty prepend="," property="Remark">		
         #Remark#		
        </isNotEmpty>
      </isPropertyAvailable>
	  </dynamic>
      )
    </sql>
	<!-- Insert statement:新增Mapper-->
    <insert id='Insert' parameterClass='Rolers'>
      <include refid="InsertPublic"/>
    </insert>
    <!--Update statement:修改Mapper-->
    <update id='Update' parameterClass='Rolers'>
      UPDATE [Rolers] 
      <include refid="UpdaterConditions"/>
      WHERE 1=1
	      </update>
    <update id='UpdateSetion' parameterClass='hashtable'>
      UPDATE [Rolers] 
      <include refid="UpdaterConditions"/>
      WHERE $conditions$
    </update>
	<update id='Save' parameterClass='Rolers'>
      IF NOT EXISTS(SELECT 1 FROM [Rolers] WHERE 1=1 )
      BEGIN
      <include refid="InsertPublic"/>
      END
      ELSE
      BEGIN
      UPDATE Rolers 
      <include refid="UpdaterConditions"/>
      WHERE  1=1
	        END
    </update>
	<delete id='Delete' parameterClass='hashtable'>
      DELETE FROM [Rolers] WHERE	  
        <![CDATA[  
	 
        ]]>
    </delete>
    <delete id='DeleteWhere' parameterClass='string'>
      DELETE FROM [Rolers] WHERE $value$
    </delete>

    <!-- select by key statement:-->
    <select id='FindOne' parameterClass='hashtable' resultClass='Rolers'>
      SELECT * FROM Rolers WHERE      
        <![CDATA[
		
        ]]>
    </select>
    <select id='FindAllCondition' parameterClass='string' resultClass='Rolers'>
      SELECT * FROM [Rolers] WHERE $value$
    </select>
    <select id='FindScalar' parameterClass='hashtable' resultClass='Rolers'>
      SELECT * FROM [Rolers] WHERE $conditions$
    </select>
    
    <select id='FindAllCount' parameterClass='string' resultClass='int'>
      SELECT COUNT(1) FROM [Rolers] WHERE $value$
    </select>
    <select id='FindByPage' parameterClass='string' resultClass='Rolers'>
      SELECT * FROM [Rolers] WHERE $value$
    </select>
  </statements>
</sqlMap>
